package com.laterem.rtc.interceptor;

import com.alibaba.excel.util.StringUtils;
import com.laterem.rtc.domain.UserDO;
import com.laterem.rtc.service.dto.UserDTO;
import com.laterem.rtc.util.UserHolder;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import java.nio.file.AccessDeniedException;
import java.util.Objects;

/**
 * @creator: alan wu
 * @dateTime: 2023/5/20 00:15
 * @desc:
 */
@Slf4j
public class AuthInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        log.info("用户开始校验");
//        String token = request.getHeader("laterem");
//        if (StringUtils.isBlank(token)){
//            throw new AccessDeniedException("请登录");
//        }
//        UserDO userDO = UserHolder.getUserDO(token);
//        if (Objects.isNull(userDO)){
//            throw new AccessDeniedException("请登录");
//        }
//        UserHolder.setId(userDO.getId());
//        return true;
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
